<template>
	<view class="collection l-whitespace">
		<view>
			<qrcode :val="qrval" :size="qrsize" ref="qrcode"></qrcode>
		</view>
		<view class="qrval van-hairline--bottom">
			<text>{{qrval}}</text>
		</view>
		<text class="clip" @click="onClipboard">点击复制钱包地址</text>
		<view class="notes color-9b">
			<text>提示：此钱包仅充值WNTC，充值其他币种会导致资产消失</text>
		</view>
	</view>
</template>
<script>
	import qrcode from '../../../components/qrcode/qrcode.vue'

	export default {
		data() {
			return {
				title: '二维码生成',
				name: '诗小柒',
				qrval: '32323232323',
				qrsize: 200,
			}
		},
		onShow () {
			this.creatQrcode()
		},
		methods: {
			creatQrcode() {
				if (!this.qrval) {
					uni.showToast({
						title: '请输入二维码内容',
						icon: 'none'
					});
					return;
				}
				this.$refs.qrcode.creatQrcode();
			},
			clearQrcode() {
				this.$refs.qrcode.clearQrcode();
			},
			onClipboard () {
				uni.setClipboardData({
					data: this.qrval,
					success: () => {
						uni.showToast({
							title: '复制成功',
							icon: 'none',
							duration: 2000
						})
					}
				});
			}
		},
		components: {
			qrcode
		}
	}
</script>
<style scoped lang="scss">
	.collection {
		padding-top: 60upx;
		margin-top: 60upx;
		text-align: center;
		.qrval {
			padding: 15upx 0;
			margin-top: 60upx;
			margin-bottom: 15upx;
			font-size: 32upx;
		}
		.clip {
			color: #5da7f3;
		}
		.notes {
			margin-top: 30upx;
		}
	}
</style>
